from coin.exchange.ftx.kr_rest.native_private_client import FTXSyncQueryer
import time

FTX_API_URL = "https://ftx.com/api/"


class FTXFuturesNativePrivateClient(object):
  def __init__(
      self,
      *,
      key_file,
      api_host=None,
      timeout=20,
      use_async=False,
  ):
    api_host = api_host or FTX_API_URL
    if use_async:
      raise NotImplementedError()
    else:
      self._auth_queryer = FTXSyncQueryer(
          key_file,
          api_host=api_host,
          timeout=timeout,
      )

  def _query(self, method, path, params=None):
    return self._auth_queryer.query(method, path, params=params)

  def query_account_balance(self):
    method = 'GET'
    path = 'wallet/balances'
    update = self._query(method, path)
    return update

  def query_account_position(self):
    method = 'GET'
    path = 'positions'
    update = self._query(method, path)
    return update
  
  def query_withdraw_history(self):
    method = 'GET'
    path = 'wallet/withdrawals'
    params={'end_time': int(time.time())}
    update = self._query(method, path, params)
    return update
  
  def query_deposit_history(self):
    method = 'GET'
    path = 'wallet/deposits'
    params={'end_time': int(time.time())}
    update = self._query(method, path, params)
    return update
